#include "LeagueStatsMenu.h"
#include "League.h"
#include "StringUtilities.h"
#include "PrintUtilities.h"
#include "MenuManager.h"
#include "ServiceProvider.h"
#include "LeagueManager.h"
#include "ClassificationMenu.h"
#include "TurnsMenu.h"
#include "LeagueHistoryMenu.h"
#include "Types.h"

LeagueStatsMenu::LeagueStatsMenu(MenuManager* const i_menuManager)
	: Menu(i_menuManager)
{
	m_leagueID = Utilities::INVALID_ID;
}

void LeagueStatsMenu::Draw() const
{
	using STD::cout;
	using STD::endl;

	cout << Print::Title(GetSP()->GetLeagueMgr().GetLeagueFromID(m_leagueID)->GetName());
	cout << endl;

	cout << "1 - Show Classification" << endl;
	cout << "2 - Show Turns" << endl;
	cout << "3 - Show League History" << endl;
	cout << endl << endl;

	STL::string options = "1-3) Menu' Selection.\n0) Return to previous menu'.";
	STD::cout << Print::Options(options) << "Selection: ";
}

bool LeagueStatsMenu::Input(const STL::string& i_input)
{
	bool goodInput = true;

	size_t res = Utilities::StringToInt(i_input);

	if (res == 0)
	{
		GetMM()->SetMenu(GetMM()->GetLeagueSelectionMenu());
	}
	else if (res == 1)
	{
		ClassificationMenu* nextMenu = static_cast<ClassificationMenu*>(GetMM()->GetClassificationMenu());
		nextMenu->SetLeagueID(m_leagueID);
		GetMM()->SetMenu(nextMenu);
	}
	else if (res == 2)
	{
		TurnsMenu* nextMenu = static_cast<TurnsMenu*>(GetMM()->GetTurnsMenu());
		nextMenu->SetLeagueID(m_leagueID);
		GetMM()->SetMenu(nextMenu);
	}
	else if (res == 3)
	{
		LeagueHistoryMenu* nextMenu = static_cast<LeagueHistoryMenu*>(GetMM()->GetLeagueHistoryMenu());
		nextMenu->SetLeagueID(m_leagueID);
		GetMM()->SetMenu(nextMenu);
	}
	else
	{
		goodInput = false;
	}

	return goodInput;
}